package user

import (
	"github.com/gin-gonic/gin"
	user2 "server/app/api/request/user"
	"server/base"
	user4 "server/common/models/user"
	"server/pkg/response"
)

var User = user{}

type user struct{}

func (*user) Info(c *gin.Context) {
	var req user2.UserIdReq
	err := c.ShouldBind(&req)
	if err != nil {
		response.Error(c, err.Error())
		return
	}

	var userInfo user4.User
	base.App.Mysql.Object.Find(&userInfo, "user_id = ?", req.UserId)
	if userInfo.UserId == 0 {
		response.Error(c, "用户不存在")
		return
	}

	var UserIntros user4.UserIntro
	base.App.Mysql.Object.Find(&UserIntros, "user_id = ?", req.UserId)

	response.Success(c, gin.H{"user": userInfo, "user_intro": UserIntros})
}
